//
// Created by yyc on 25-8-5.
//
#include "servo_control.h"
#include "tim.h"
#include "usart.h"
#include "main.h"
#include "angle_upload.h"
#include "gpio.h"
void servo_control_init(void)
{
   HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);
   angle=0;
}
void servo_set_angle(uint8_t angle)
{
   uint16_t pulse = 500 + angle * 2000 / 180;  // 0.5ms ~ 2.5ms
   __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4, pulse);

}